<?php
  
  include_once("contacts.inc.php");
  		
	$reqUsername = $_GET['user'];
	$reqPassword = $_GET['pw'];
	$reqCommand = $_GET['cmd'];
  $reqGroup = $_GET["group"];
  $reqContact = $_GET["contact"];
	
  header("Content-type: text/xml");
  
  switch($reqCommand)
  {
  	case 'data':
  		$contacts = loadContacts();
  		echo exportXML($contacts);
  		break;
  		
  	case 'import':	
  		header("Location: ../index.html");
  		
  		echo importData();
  		break;
  		
  	case 'export':
  		echo 'TODO: export';
  		break;
  		
  	case 'update':
  		echo 'TODO: update';
  		break;
  		
  	case 'loggedin':
  		echo isLoggedin();
  		break;
  		
  	case 'login':
  		echo login();
  		break;
  	
		case 'logout':
			echo logout();
  		break;
  	
		case 'add':
  		header("Location: ../index.html");
  		
			echo addContactData();
  		break;
  	
		case 'delete':
			echo deleteContactData();
  		break;
  		
  	default:
  		echo 'Error: Command not recognized';
  		break;
  }
  
?>